<? //include/SUPPLIERS_session.php

include("SUPPLIERS.php");

require_once'../include/database.php';
$conn = new Connection();
$conn->NewConnection('localhost','ecommerce','root','batavia');
class SessionSUPPLIERS { 


 
 function find($id){
    
   global $conn;
   
   $query = "select SupplierID,CompanyName,ContactFName,ContactLName,ContactTitle,Address1,Address2,City,State,PostalCode,Country,Phone,Fax,Email,WebSite,PaymentMethods,DiscountType,DiscountRate,TypeGoods,DiscountAvailable,CurrentOrder,CustomerID,SizeURL,Logo,Ranking,Note from SUPPLIERS where SupplierID='$id'";
   
   $run = mysql_query($query) or die(mysql_error());
   
   $row = mysql_fetch_array($run, MYSQL_ASSOC);
   
   $numRow = mysql_numrows($run);
   
   if($numRow)
   
   {
   
   $this->SUPPLIERS= new SUPPLIERS();


   
	$this->SUPPLIERS->setSupplierID($row['SupplierID']);

 
	$this->SUPPLIERS->setCompanyName($row['CompanyName']);

 
	$this->SUPPLIERS->setContactFName($row['ContactFName']);

 
	$this->SUPPLIERS->setContactLName($row['ContactLName']);

 
	$this->SUPPLIERS->setContactTitle($row['ContactTitle']);

 
	$this->SUPPLIERS->setAddress1($row['Address1']);

 
	$this->SUPPLIERS->setAddress2($row['Address2']);

 
	$this->SUPPLIERS->setCity($row['City']);

 
	$this->SUPPLIERS->setState($row['State']);

 
	$this->SUPPLIERS->setPostalCode($row['PostalCode']);

 
	$this->SUPPLIERS->setCountry($row['Country']);

 
	$this->SUPPLIERS->setPhone($row['Phone']);

 
	$this->SUPPLIERS->setFax($row['Fax']);

 
	$this->SUPPLIERS->setEmail($row['Email']);

 
	$this->SUPPLIERS->setWebSite($row['WebSite']);

 
	$this->SUPPLIERS->setPaymentMethods($row['PaymentMethods']);

 
	$this->SUPPLIERS->setDiscountType($row['DiscountType']);

 
	$this->SUPPLIERS->setDiscountRate($row['DiscountRate']);

 
	$this->SUPPLIERS->setTypeGoods($row['TypeGoods']);

 
	$this->SUPPLIERS->setDiscountAvailable($row['DiscountAvailable']);

 
	$this->SUPPLIERS->setCurrentOrder($row['CurrentOrder']);

 
	$this->SUPPLIERS->setCustomerID($row['CustomerID']);

 
	$this->SUPPLIERS->setSizeURL($row['SizeURL']);

 
	$this->SUPPLIERS->setLogo($row['Logo']);

 
	$this->SUPPLIERS->setRanking($row['Ranking']);

 
	$this->SUPPLIERS->setNote($row['Note']);

 
}
return $this->SUPPLIERS;
}

function insert($SUPPLIERS){
	global $conn;
	$query = "insert into SUPPLIERS(SupplierID,CompanyName,ContactFName,ContactLName,ContactTitle,Address1,Address2,City,State,PostalCode,Country,Phone,Fax,Email,WebSite,PaymentMethods,DiscountType,DiscountRate,TypeGoods,DiscountAvailable,CurrentOrder,CustomerID,SizeURL,Logo,Ranking,Note) values('".$SUPPLIERS->getSupplierID()."','".$SUPPLIERS->getCompanyName()."','".$SUPPLIERS->getContactFName()."','".$SUPPLIERS->getContactLName()."','".$SUPPLIERS->getContactTitle()."','".$SUPPLIERS->getAddress1()."','".$SUPPLIERS->getAddress2()."','".$SUPPLIERS->getCity()."','".$SUPPLIERS->getState()."','".$SUPPLIERS->getPostalCode()."','".$SUPPLIERS->getCountry()."','".$SUPPLIERS->getPhone()."','".$SUPPLIERS->getFax()."','".$SUPPLIERS->getEmail()."','".$SUPPLIERS->getWebSite()."','".$SUPPLIERS->getPaymentMethods()."','".$SUPPLIERS->getDiscountType()."','".$SUPPLIERS->getDiscountRate()."','".$SUPPLIERS->getTypeGoods()."','".$SUPPLIERS->getDiscountAvailable()."','".$SUPPLIERS->getCurrentOrder()."','".$SUPPLIERS->getCustomerID()."','".$SUPPLIERS->getSizeURL()."','".$SUPPLIERS->getLogo()."','".$SUPPLIERS->getRanking()."','".$SUPPLIERS->getNote()."')";
 
 $parse=mysql_query($query);

 }
 
 function findall(){
	$query = "select SupplierID,CompanyName,ContactFName,ContactLName,ContactTitle,Address1,Address2,City,State,PostalCode,Country,Phone,Fax,Email,WebSite,PaymentMethods,DiscountType,DiscountRate,TypeGoods,DiscountAvailable,CurrentOrder,CustomerID,SizeURL,Logo,Ranking,Note from SUPPLIERS";
	$parse=mysql_query($query);
	$datas = array();
	while($row=mysql_fetch_assoc($parse))
	{
		$data = array();$data['SupplierID'] = $row['SupplierID'];
		$data['CompanyName'] = $row['CompanyName'];
		$data['ContactFName'] = $row['ContactFName'];
		$data['ContactLName'] = $row['ContactLName'];
		$data['ContactTitle'] = $row['ContactTitle'];
		$data['Address1'] = $row['Address1'];
		$data['Address2'] = $row['Address2'];
		$data['City'] = $row['City'];
		$data['State'] = $row['State'];
		$data['PostalCode'] = $row['PostalCode'];
		$data['Country'] = $row['Country'];
		$data['Phone'] = $row['Phone'];
		$data['Fax'] = $row['Fax'];
		$data['Email'] = $row['Email'];
		$data['WebSite'] = $row['WebSite'];
		$data['PaymentMethods'] = $row['PaymentMethods'];
		$data['DiscountType'] = $row['DiscountType'];
		$data['DiscountRate'] = $row['DiscountRate'];
		$data['TypeGoods'] = $row['TypeGoods'];
		$data['DiscountAvailable'] = $row['DiscountAvailable'];
		$data['CurrentOrder'] = $row['CurrentOrder'];
		$data['CustomerID'] = $row['CustomerID'];
		$data['SizeURL'] = $row['SizeURL'];
		$data['Logo'] = $row['Logo'];
		$data['Ranking'] = $row['Ranking'];
		$data['Note'] = $row['Note'];
		$datas[] = $data;
	 }
	return $datas;
	}
	function delete($SUPPLIERS){
	$query = "delete from SUPPLIERS where SupplierID= '".$SUPPLIERS->getSupplierID()."'";
	$parse=mysql_query($query);
	return $parse;

	}
	
	function update($SUPPLIERS){
	$query = "update SUPPLIERS set CompanyName= '".$SUPPLIERS->getCompanyName()."',ContactFName= '".$SUPPLIERS->getContactFName()."',ContactLName= '".$SUPPLIERS->getContactLName()."',ContactTitle= '".$SUPPLIERS->getContactTitle()."',Address1= '".$SUPPLIERS->getAddress1()."',Address2= '".$SUPPLIERS->getAddress2()."',City= '".$SUPPLIERS->getCity()."',State= '".$SUPPLIERS->getState()."',PostalCode= '".$SUPPLIERS->getPostalCode()."',Country= '".$SUPPLIERS->getCountry()."',Phone= '".$SUPPLIERS->getPhone()."',Fax= '".$SUPPLIERS->getFax()."',Email= '".$SUPPLIERS->getEmail()."',WebSite= '".$SUPPLIERS->getWebSite()."',PaymentMethods= '".$SUPPLIERS->getPaymentMethods()."',DiscountType= '".$SUPPLIERS->getDiscountType()."',DiscountRate= '".$SUPPLIERS->getDiscountRate()."',TypeGoods= '".$SUPPLIERS->getTypeGoods()."',DiscountAvailable= '".$SUPPLIERS->getDiscountAvailable()."',CurrentOrder= '".$SUPPLIERS->getCurrentOrder()."',CustomerID= '".$SUPPLIERS->getCustomerID()."',SizeURL= '".$SUPPLIERS->getSizeURL()."',Logo= '".$SUPPLIERS->getLogo()."',Ranking= '".$SUPPLIERS->getRanking()."',Note= '".$SUPPLIERS->getNote()."' where SupplierID= '".$SUPPLIERS->getSupplierID()."'";
$parse=mysql_query($query);

}


}
 //include/SUPPLIERS_session.php